package experiment4;

import java.util.Scanner;

public class No_4 {
    public static void main(String []args)
    {
        Vehicle new_Vehicle=new Vehicle();
        new_Vehicle.speed=0;
        new_Vehicle.type="公交车";

        new_Vehicle.move();
        System.out.println("现在的速度是"+new_Vehicle.speed);
        new_Vehicle.setSpeed();
        new_Vehicle.speedUp();
        new_Vehicle.speedDown();


    }
}
class Vehicle{
    public double speed;
    public String type;

    /**启动*/
    public void move()
    {
        if(speed==0)
        {
            speed=1;
        }
    }

    public void setSpeed()
    {
        System.out.println("请输入速度:");
        Scanner input=new Scanner(System.in);
        speed=input.nextDouble();
        System.out.println("现在的速度是"+speed);
    }

    public void speedUp()
    {
        speed++;
        System.out.println("现在的速度是"+speed);
    }

    public void speedDown()
    {
        speed--;
        System.out.println("现在的速度是"+speed);
    }

}
